<?php

namespace App\Models;

use App\Observers\EduZanObserver;
use App\User;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;

class EduZan extends Model
{
    //引入全站动态日志类
    use LogsActivity;
    protected static $logName = 'edu_zan';
    //设置全站动态日志关注的动作
    protected static $recordEvents = ['created','updated'];
    protected $fillable = [
        'zan_id','zan_type','user_id'
    ];
    public function user(){
        return $this->belongsTo(User::class);
    }

    public static function boot()
    {
        self::observe(EduZanObserver::class);
        parent::boot(); // TODO: Change the autogenerated stub
    }



    //获取拥有某个点赞的模型
    public function getZanModel(){
        return $this->morphTo('zan');
    }

    //创建一个link()方法用来指定这个模型动态的展示地址
    function link(){
            dd('EduZan 中的 link 方法');
    }





}
